//返回值为需不需要关闭窗口
function yesOperator(){
  var retValue=addData();
  return retValue;
}
function updateLoad(){
    var params = $$.getQueryString();
    $$.ajax({
        url:"/rest/IotCalczDirectionBusiness/query",
        data : {
            id : params.rowId
        },
        success : function(data){
        	 $("#b_id").val(data.id);
                                        $("#b_stable").val(data.stable);

                           $("#b_scode").val(data.scode);

                           $("#b_ttable").val(data.ttable);

                           $("#b_tcode").val(data.tcode);

                           $("#b_cfunc").val(data.cfunc);

                           $("#b_status").val(data.status);

                           $("#b_remarks").val(data.remarks);


                 var status=data.status; 

            $("input[name^='b_status_']").each(function(){ 

        if($(this).val()==status){ 

             this.checked='checked'; 

         } 

        }); 



            $("#b_calczCodeOld").val(data.calczCode);
           


        }
    });



}
function validForm(){
      return $('#theform').valid();
	 
    /*
    //判断编码唯一性
    if(!notNull("b_calczCode","正向计算编码")){
        return false;
    }
    var calczCodeOld=$("#b_calczCodeOld").val();
    var calczCode=$("#b_calczCode").val();
    if(calczCodeOld==calczCode){

    }else{

            var args={};
            args.c_calczCode_1=$("#b_calczCode").val();
            args.page=0;
            args.pageSize=5;
            args.isPage=1;


            var exists;
            $$.ajax({
                url: "/bootstrap/basegrid/IotCalczDirectionBusiness/list",
                async:false,
                data: args,
                success: function (data) {
                    if(data.length && data.length>0){
                        exists=true;
                     }else{
                        exists=false;
                    }
                }
            });
            if(exists){
               $$.alert("正向计算编码已经存在,请重新输入!",function(index){
                   layer.close(index);
                   $("#b_calczCode").focus();
               });
               return false;
             }

    }
    */

}
function addData(){
    var param = {};
    var validFormRet;
    $$.form({
        async:false,
        able:function(){
            validFormRet=false;
        },
        checkForm: validForm,
        success: function () {
            validFormRet= true;
        }
    });
    return validFormRet;
}

function forwardCalcValid() {
    $("#theform").validate({
        rules: {
            b_stable: {
                required: true,
                minlength: 1
            },
            b_scode: {
                required: true,
                minlength: 1,
            },
            b_ttable: {
                required: true,
                minlength: 1,
                //isCode:true
            },
            b_tcode: {
                required: true,
                minlength: 1,
            },
            b_cfunc_1: {
                required: true,
                minlength: 1,
                //isCode:true
            },
            b_rowSort: {
                required: true,
                minlength: 1,
                number: true,
            }
        },
        errorPlacement: function(error, element) {
            error.appendTo(element.parent());
        },
        errorElement: "span",
        errorClass: "errortips",
        success: 'valid',
        messages: {
            b_stable: {
                required: " (必填字段)",
                minlength: " (不能少于 1 个字母)",
                number: "请输入数字",
            },
            b_scode: {
                required: " (必填字段)",
                minlength: " (不能少于 1 个字母)",
            },
            b_ttable:{
                required: " (必填字段)",
                minlength: " (不能少于 1 个字母)"
            },
            b_tcode:{
                required: " (必填字段)",
                minlength: " (不能少于6位密码)"
            },
            b_cfunc_1:{
                required: " (必填字段)",
                minlength: " (不能少于 1 个字母)"
            },
            b_rowSort:{
                required: " (必填字段)",
                minlength: " (不能少于1位)",
                number: "请输入数字",
            }
        },
    });
}

$(function () {
    forwardCalcValid();
    $("input[name^='b_status']").click(function(){
        $("#b_status").val($(this).val());
    });
});
